local skel = fk.CreateSkill {
  name = "emo__daogeng",
}

skel:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "savage_assault",
  card_filter = Util.FalseFunc,
  prompt = "#emo__daogeng",
  view_as = function(self, player)
    local c = Fk:cloneCard("savage_assault")
    c.skillName = skel.name
    c:addSubcards(player:getCardIds("h"))
    return c
  end,
  before_use = function(self, player, use)
    use.extra_data = use.extra_data or {}
    use.extra_data.emo__daogeng_from = player.id
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
  end,
  enabled_at_response = Util.FalseFunc,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
})

skel:addLoseEffect(function (self, player, is_death)
  player.room:setPlayerMark(player, "@emo__daogeng", 0)
end)

skel:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card)
    return card and card.trueName == "slash" and player:getMark("@emo__daogeng") > 0
  end,
})

skel:addEffect(fk.Damage, {
  can_refresh = function(self, event, target, player, data)
    if player.dead then return false end
    local useEvent = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    if useEvent then
      local use = useEvent.data
      return use.card == data.card and (use.extra_data or {}).emo__daogeng_from == player.id
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@emo__daogeng")
  end,
})

skel:addEffect(fk.PreCardUse, {
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card.trueName == "slash" and player:getMark("@emo__daogeng") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:removePlayerMark(player, "@emo__daogeng")
    data.extraUse = true
  end,
})

Fk:loadTranslationTable{
  ["emo__daogeng"] = "刀耕",
  [":emo__daogeng"] = "出牌阶段限一次，你可以将所有手牌当【南蛮入侵】使用；此牌造成伤害后，令你下一张【杀】便无次数限制。",

  ["#emo__daogeng"] = "刀耕：将所有手牌当【南蛮入侵】使用",
  ["@emo__daogeng"] = "刀耕",
}


return skel
